<?php

namespace app\webapi\vms\validate;

use app\webapi\common\BaseValidate;

/**
 * @站点验证类
 */
class WebsiteValidate extends BaseValidate
{
    //验证规则
    protected $rule = [
        'logo' => 'url|length:6,128',
        'name' => 'require|length:2,16',
        'language' => 'in:cn',
        'template_id' => 'require|number',
        'domain_name' => 'require|regex:[a-zA-Z0-9]{6,16}',
        'status' => 'in:1,2',
        'copyright' => 'length:6,32',
        'seo_title' => 'length:0,32',
        'seo_keywords' => 'length:0,128',
        'seo_desc' => 'length:0,2048',
        'channel_name' => 'require|length:2,16',
        'subtitle' => 'length:2,16',
        'channel_id' => 'require|number',
        'sign' => 'require',
        'icon' => 'url',
    ];

    //验证消息
    protected $message = [
        'name.require' => '网站名称必填',
        'name.length' => '网站名称长度必须在2-16位之间',
        'logo.url' => '网站logo不是有效的url地址',
        'logo.length' => '网站logo长度在6-128位之间',
        'language.in' => '语言必须是中文',
        'template_id.require' => '模板id必填',
        'template_id.number' => '模板id必须是数字',
        'domain_name.regex' => '域名名称必须由数字和字母组成,长度必须是6-16位',
        'status.in' => '状态可选值为1,2',
        'copyright.length' => '版权信息长度为6-32位',
        'seo_title.length' => 'seo标题长度为0-32位',
        'seo_keywords.length' => 'seo关键字长度为0-32位',
        'seo_desc.length' => 'seo描述长度为0-32位',
        'channel_name.require' => '栏目名称必填',
        'channel_name.length' => '栏目名称长度必须在2-16位之间',
        'subtitle.length' => '栏目副标题长度必须在2-16位之间',
        'channel_id.require' => '栏目id必填',
        'channel_id.number' => '栏目id必须是整型',
        'sign.require' => '获取token标识必填',
        'icon.url' => '地址栏图标不是有效的url地址',
    ];

    //验证场景
    protected $scene = [
        'getToken' => ['sign'],
        'setBaseDomain' => ['domain_name'],
        'setBaseInfo' => ['name', 'language','logo'],
        'changeStatus' => ['status'],
        'bindCustomDomain' => ['domain_name'],
        'setRecordNumber' => ['domain_record_number'],
        'editChannel' => ['channel_name', 'subtitle', 'id'],
        'getChannelInfo' => ['channel_id'],
        'sortChannel' => [''],
        'setAllInfo' => ['name', 'language','logo','status','copyright','seo_title','seo_keywords','seo_desc','icon'],
    ];

}